1// Copyright 2013 The Flutter Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5library fuchsia_builtin; 6 7import 'dart:async'; 8import 'dart:io'; 9import 'dart:_internal' show VMLibraryHooks; 10 11// Corelib 'print' implementation. 12void _print(arg) { 13 _Logger._printString(arg.toString()); 14 try { 15 // If stdout is connected, print to it as well. 16 stdout.writeln(arg); 17 } on FileSystemException catch (_) { 18 // Some Fuchsia applications will not have stdout connected. 19 } 20} 21 22class _Logger { 23 static void _printString(String s) native "Logger_PrintString"; 24} 25 26@pragma('vm:entry-point') 27String _rawScript; 28 29Uri _scriptUri() { 30 if (_rawScript.startsWith('http:') || 31 _rawScript.startsWith('https:') || 32 _rawScript.startsWith('file:')) { 33 return Uri.parse(_rawScript); 34 } else { 35 return Uri.base.resolveUri(Uri.file(_rawScript)); 36 } 37} 38 39void _scheduleMicrotask(void callback()) native "ScheduleMicrotask"; 40 41@pragma('vm:entry-point') 42_getScheduleMicrotaskClosure() => _scheduleMicrotask; 43 44@pragma('vm:entry-point') 45_setupHooks() { 46 VMLibraryHooks.platformScript = _scriptUri; 47} 48 49@pragma('vm:entry-point') 50_getPrintClosure() => _print; 51